﻿<!DOCTYPE html>
<html>
<head>
    <title>JS Conditional Exercise 1</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <h1>Exchanges values if the first number is greater than the second one</h1>
    <div>
        <label for="num1">Number 1:</label>
        <input type="number" id="num1" />
        <label for="num2">Number 2:</label>
        <input type="number" id="num2" />
        <button onclick="execute()">Execute</button>
    </div>
    <div id="js-console"></div>
    <script src="scripts/js-console.js"></script>
    <script>
        function execute()
        {
            var numA = jsConsole.readInteger("#num1");
            var numB = jsConsole.readInteger("#num2");

            if (numA > numB)
            {
                // Exchange values
                numA = numA + numB;
                numB = numA - numB;
                numA = numA - numB;
            }

            jsConsole.writeLine("Number 1: " + numA + " Number 2: " + numB);
        }
    </script>
</body>
</html>
